@dxos/react-ui-editor 0.8.2 → 0.8.3-main.672df60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/lib/browser/index.mjs +159 -105
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +172 -119
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +159 -105
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/extensions/command/menu.d.ts.map +1 -1
  11. package/dist/types/src/extensions/hashtag.d.ts +3 -0
  12. package/dist/types/src/extensions/hashtag.d.ts.map +1 -0
  13. package/dist/types/src/extensions/index.d.ts +1 -0
  14. package/dist/types/src/extensions/index.d.ts.map +1 -1
  15. package/dist/types/src/extensions/json.d.ts.map +1 -1
  16. package/dist/types/src/extensions/markdown/debug.d.ts +2 -2
  17. package/dist/types/src/extensions/markdown/debug.d.ts.map +1 -1
  18. package/dist/types/src/extensions/outliner/outliner.d.ts +1 -3
  19. package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
  20. package/dist/types/src/stories/Command.stories.d.ts +1 -1
  21. package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
  22. package/dist/types/src/stories/Comments.stories.d.ts +1 -1
  23. package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
  24. package/dist/types/src/stories/Experimental.stories.d.ts +1 -1
  25. package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
  26. package/dist/types/src/stories/Markdown.stories.d.ts +1 -1
  27. package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
  28. package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
  29. package/dist/types/src/stories/Preview.stories.d.ts +1 -1
  30. package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
  31. package/dist/types/src/stories/TextEditor.stories.d.ts +1 -1
  32. package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
  33. package/dist/types/src/stories/components/EditorStory.d.ts +43 -0
  34. package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -0
  35. package/dist/types/src/stories/components/index.d.ts +3 -0
  36. package/dist/types/src/stories/components/index.d.ts.map +1 -0
  37. package/dist/types/src/stories/{util.d.ts → components/util.d.ts} +3 -18
  38. package/dist/types/src/stories/components/util.d.ts.map +1 -0
  39. package/package.json +28 -27
  40. package/src/extensions/command/menu.ts +31 -22
  41. package/src/extensions/hashtag.tsx +68 -0
  42. package/src/extensions/index.ts +1 -0
  43. package/src/extensions/json.ts +2 -1
  44. package/src/extensions/markdown/debug.ts +2 -2
  45. package/src/extensions/outliner/outliner.ts +9 -8
  46. package/src/stories/Command.stories.tsx +1 -1
  47. package/src/stories/Comments.stories.tsx +2 -2
  48. package/src/stories/Experimental.stories.tsx +2 -2
  49. package/src/stories/Markdown.stories.tsx +2 -2
  50. package/src/stories/Outliner.stories.tsx +19 -7
  51. package/src/stories/Preview.stories.tsx +2 -2
  52. package/src/stories/TextEditor.stories.tsx +3 -3
  53. package/src/stories/components/EditorStory.tsx +135 -0
  54. package/src/stories/components/index.ts +6 -0
  55. package/src/stories/{util.tsx → components/util.tsx} +5 -100
  56. package/dist/types/src/stories/util.d.ts.map +0 -1
@@ -35,7 +35,7 @@ var translations_default = [
35
35
 
36
36
  // packages/ui/react-ui-editor/src/index.ts
37
37
  import { EditorState as EditorState4 } from "@codemirror/state";
38
- import { EditorView as EditorView24, keymap as keymap13 } from "@codemirror/view";
38
+ import { EditorView as EditorView25, keymap as keymap13 } from "@codemirror/view";
39
39
  import { tags as tags2 } from "@lezer/highlight";
40
40
  import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
41
41
 
@@ -1459,26 +1459,36 @@ var command = (options = {}) => {
1459
1459
 
1460
1460
  // packages/ui/react-ui-editor/src/extensions/command/menu.ts
1461
1461
  import { EditorView as EditorView7, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
1462
+ import { addEventListener } from "@dxos/async";
1462
1463
  var floatingMenu = (options = {}) => [
1463
1464
  ViewPlugin5.fromClass(class {
1464
1465
  constructor(view) {
1465
- this.rafId = null;
1466
1466
  this.view = view;
1467
1467
  const container = view.scrollDOM;
1468
1468
  if (getComputedStyle(container).position === "static") {
1469
1469
  container.style.position = "relative";
1470
1470
  }
1471
- const icon = document.createElement("dx-icon");
1472
- icon.setAttribute("icon", options.icon ?? "ph--dots-three-outline--regular");
1473
- const button = document.createElement("button");
1474
- button.appendChild(icon);
1475
- this.tag = document.createElement("dx-ref-tag");
1476
- this.tag.classList.add("cm-ref-tag");
1477
- this.tag.appendChild(button);
1471
+ {
1472
+ const icon = document.createElement("dx-icon");
1473
+ icon.setAttribute("icon", options.icon ?? "ph--dots-three-vertical--regular");
1474
+ const button = document.createElement("button");
1475
+ button.appendChild(icon);
1476
+ this.tag = document.createElement("dx-ref-tag");
1477
+ this.tag.classList.add("cm-ref-tag");
1478
+ this.tag.appendChild(button);
1479
+ }
1478
1480
  container.appendChild(this.tag);
1479
- container.addEventListener("scroll", this.scheduleUpdate.bind(this));
1481
+ const handler = () => this.scheduleUpdate();
1482
+ this.cleanup = addEventListener(container, "scroll", handler);
1480
1483
  this.scheduleUpdate();
1481
1484
  }
1485
+ destroy() {
1486
+ this.cleanup?.();
1487
+ this.tag.remove();
1488
+ if (this.rafId != null) {
1489
+ cancelAnimationFrame(this.rafId);
1490
+ }
1491
+ }
1482
1492
  update(update2) {
1483
1493
  this.tag.dataset.focused = update2.view.hasFocus ? "true" : "false";
1484
1494
  if (!update2.view.hasFocus) {
@@ -1515,20 +1525,19 @@ var floatingMenu = (options = {}) => [
1515
1525
  }
1516
1526
  this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
1517
1527
  }
1518
- destroy() {
1519
- this.tag.remove();
1520
- if (this.rafId != null) {
1521
- cancelAnimationFrame(this.rafId);
1522
- }
1523
- }
1524
1528
  }),
1525
1529
  EditorView7.theme({
1526
1530
  ".cm-ref-tag": {
1527
1531
  position: "fixed",
1528
1532
  padding: "0",
1529
1533
  border: "none",
1530
- transition: "opacity 0.3s ease-in-out",
1531
- opacity: 0.1
1534
+ opacity: "0"
1535
+ },
1536
+ "[data-has-focus] & .cm-ref-tag": {
1537
+ opacity: "1"
1538
+ },
1539
+ "[data-is-attention-source] & .cm-ref-tag": {
1540
+ opacity: "1"
1532
1541
  },
1533
1542
  ".cm-ref-tag button": {
1534
1543
  display: "grid",
@@ -1536,9 +1545,6 @@ var floatingMenu = (options = {}) => [
1536
1545
  justifyContent: "center",
1537
1546
  width: "2rem",
1538
1547
  height: "2rem"
1539
- },
1540
- '.cm-ref-tag[data-focused="true"]': {
1541
- opacity: 1
1542
1548
  }
1543
1549
  })
1544
1550
  ];
@@ -2647,6 +2653,49 @@ var folding = (_props = {}) => [
2647
2653
  })
2648
2654
  ];
2649
2655
 
2656
+ // packages/ui/react-ui-editor/src/extensions/hashtag.tsx
2657
+ import { Decoration as Decoration6, EditorView as EditorView14, MatchDecorator, ViewPlugin as ViewPlugin9, WidgetType as WidgetType3 } from "@codemirror/view";
2658
+ import { getHashColor, mx as mx2 } from "@dxos/react-ui-theme";
2659
+ var TagWidget = class extends WidgetType3 {
2660
+ constructor(_text) {
2661
+ super(), this._text = _text;
2662
+ }
2663
+ toDOM() {
2664
+ const span = document.createElement("span");
2665
+ span.className = mx2("cm-tag", getHashColor(this._text).tag);
2666
+ span.textContent = this._text;
2667
+ return span;
2668
+ }
2669
+ };
2670
+ var tagMatcher = new MatchDecorator({
2671
+ regexp: /#(\w+)\W/g,
2672
+ decoration: (match) => Decoration6.replace({
2673
+ widget: new TagWidget(match[1])
2674
+ })
2675
+ });
2676
+ var hashtag = () => [
2677
+ ViewPlugin9.fromClass(class {
2678
+ constructor(view) {
2679
+ this.tags = tagMatcher.createDeco(view);
2680
+ }
2681
+ update(update2) {
2682
+ this.tags = tagMatcher.updateDeco(update2, this.tags);
2683
+ }
2684
+ }, {
2685
+ decorations: (instance) => instance.tags,
2686
+ provide: (plugin) => EditorView14.atomicRanges.of((view) => {
2687
+ return view.plugin(plugin)?.tags || Decoration6.none;
2688
+ })
2689
+ }),
2690
+ EditorView14.theme({
2691
+ ".cm-tag": {
2692
+ borderRadius: "4px",
2693
+ marginRight: "6px",
2694
+ padding: "2px 6px"
2695
+ }
2696
+ })
2697
+ ];
2698
+
2650
2699
  // packages/ui/react-ui-editor/src/extensions/json.ts
2651
2700
  import { json, jsonParseLinter } from "@codemirror/lang-json";
2652
2701
  import { linter } from "@codemirror/lint";
@@ -2655,7 +2704,8 @@ var createJsonExtensions = ({ schema } = {}) => {
2655
2704
  let lintSource = jsonParseLinter();
2656
2705
  if (schema) {
2657
2706
  const ajv = new Ajv({
2658
- allErrors: false
2707
+ allErrors: false,
2708
+ strict: false
2659
2709
  });
2660
2710
  const validate = ajv.compile(schema);
2661
2711
  lintSource = schemaLinter(validate);
@@ -2692,14 +2742,14 @@ var schemaLinter = (validate) => (view) => {
2692
2742
  };
2693
2743
 
2694
2744
  // packages/ui/react-ui-editor/src/extensions/listener.ts
2695
- import { EditorView as EditorView14 } from "@codemirror/view";
2745
+ import { EditorView as EditorView15 } from "@codemirror/view";
2696
2746
  var listener = ({ onFocus, onChange }) => {
2697
2747
  const extensions = [];
2698
- onFocus && extensions.push(EditorView14.focusChangeEffect.of((_, focusing) => {
2748
+ onFocus && extensions.push(EditorView15.focusChangeEffect.of((_, focusing) => {
2699
2749
  onFocus(focusing);
2700
2750
  return null;
2701
2751
  }));
2702
- onChange && extensions.push(EditorView14.updateListener.of((update2) => {
2752
+ onChange && extensions.push(EditorView15.updateListener.of((update2) => {
2703
2753
  onChange(update2.state.doc.toString(), update2.state.facet(documentId));
2704
2754
  }));
2705
2755
  return extensions;
@@ -2709,7 +2759,7 @@ var listener = ({ onFocus, onChange }) => {
2709
2759
  import { snippet } from "@codemirror/autocomplete";
2710
2760
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
2711
2761
  import { EditorSelection as EditorSelection2 } from "@codemirror/state";
2712
- import { EditorView as EditorView15, keymap as keymap8 } from "@codemirror/view";
2762
+ import { EditorView as EditorView16, keymap as keymap8 } from "@codemirror/view";
2713
2763
  import { useMemo as useMemo2 } from "react";
2714
2764
  var formattingEquals = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
2715
2765
  var Inline = /* @__PURE__ */ function(Inline2) {
@@ -3798,7 +3848,7 @@ var getFormatting = (state) => {
3798
3848
  };
3799
3849
  };
3800
3850
  var useFormattingState = (state) => {
3801
- return useMemo2(() => EditorView15.updateListener.of((update2) => {
3851
+ return useMemo2(() => EditorView16.updateListener.of((update2) => {
3802
3852
  if (update2.docChanged || update2.selectionSet) {
3803
3853
  Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
3804
3854
  state[key] = active;
@@ -4111,16 +4161,16 @@ var convertTreeToJson = (state) => {
4111
4161
  // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
4112
4162
  import { syntaxTree as syntaxTree7 } from "@codemirror/language";
4113
4163
  import { RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect5 } from "@codemirror/state";
4114
- import { EditorView as EditorView19, Decoration as Decoration8, WidgetType as WidgetType5, ViewPlugin as ViewPlugin10 } from "@codemirror/view";
4164
+ import { EditorView as EditorView20, Decoration as Decoration9, WidgetType as WidgetType6, ViewPlugin as ViewPlugin11 } from "@codemirror/view";
4115
4165
  import { invariant as invariant4 } from "@dxos/invariant";
4116
- import { mx as mx2 } from "@dxos/react-ui-theme";
4166
+ import { mx as mx3 } from "@dxos/react-ui-theme";
4117
4167
 
4118
4168
  // packages/ui/react-ui-editor/src/extensions/markdown/changes.ts
4119
4169
  import { syntaxTree as syntaxTree4 } from "@codemirror/language";
4120
4170
  import { Transaction as Transaction2 } from "@codemirror/state";
4121
- import { ViewPlugin as ViewPlugin9 } from "@codemirror/view";
4171
+ import { ViewPlugin as ViewPlugin10 } from "@codemirror/view";
4122
4172
  var adjustChanges = () => {
4123
- return ViewPlugin9.fromClass(class {
4173
+ return ViewPlugin10.fromClass(class {
4124
4174
  update(update2) {
4125
4175
  const tree = syntaxTree4(update2.state);
4126
4176
  const adjustments = [];
@@ -4262,12 +4312,12 @@ var getValidUrl = (str) => {
4262
4312
  // packages/ui/react-ui-editor/src/extensions/markdown/image.ts
4263
4313
  import { syntaxTree as syntaxTree5 } from "@codemirror/language";
4264
4314
  import { StateField as StateField7 } from "@codemirror/state";
4265
- import { Decoration as Decoration6, EditorView as EditorView16, WidgetType as WidgetType3 } from "@codemirror/view";
4315
+ import { Decoration as Decoration7, EditorView as EditorView17, WidgetType as WidgetType4 } from "@codemirror/view";
4266
4316
  var image = (_options = {}) => {
4267
4317
  return [
4268
4318
  StateField7.define({
4269
4319
  create: (state) => {
4270
- return Decoration6.set(buildDecorations(0, state.doc.length, state));
4320
+ return Decoration7.set(buildDecorations(0, state.doc.length, state));
4271
4321
  },
4272
4322
  update: (value, tr) => {
4273
4323
  if (!tr.docChanged && !tr.selection) {
@@ -4290,7 +4340,7 @@ var image = (_options = {}) => {
4290
4340
  add: buildDecorations(from, to, tr.state)
4291
4341
  });
4292
4342
  },
4293
- provide: (field) => EditorView16.decorations.from(field)
4343
+ provide: (field) => EditorView17.decorations.from(field)
4294
4344
  })
4295
4345
  ];
4296
4346
  };
@@ -4308,7 +4358,7 @@ var buildDecorations = (from, to, state) => {
4308
4358
  return;
4309
4359
  }
4310
4360
  preloadImage(url);
4311
- decorations2.push(Decoration6.replace({
4361
+ decorations2.push(Decoration7.replace({
4312
4362
  block: true,
4313
4363
  widget: new ImageWidget(url)
4314
4364
  }).range(hide2 ? node.from : node.to, node.to));
@@ -4328,7 +4378,7 @@ var preloadImage = (url) => {
4328
4378
  preloaded.add(url);
4329
4379
  }
4330
4380
  };
4331
- var ImageWidget = class extends WidgetType3 {
4381
+ var ImageWidget = class extends WidgetType4 {
4332
4382
  constructor(_url) {
4333
4383
  super(), this._url = _url;
4334
4384
  }
@@ -4349,10 +4399,10 @@ var ImageWidget = class extends WidgetType3 {
4349
4399
  };
4350
4400
 
4351
4401
  // packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
4352
- import { EditorView as EditorView17 } from "@codemirror/view";
4402
+ import { EditorView as EditorView18 } from "@codemirror/view";
4353
4403
  var bulletListIndentationWidth = 24;
4354
4404
  var orderedListIndentationWidth = 36;
4355
- var formattingStyles = EditorView17.theme({
4405
+ var formattingStyles = EditorView18.theme({
4356
4406
  /**
4357
4407
  * Horizontal rule.
4358
4408
  */
@@ -4474,12 +4524,12 @@ var formattingStyles = EditorView17.theme({
4474
4524
  // packages/ui/react-ui-editor/src/extensions/markdown/table.ts
4475
4525
  import { syntaxTree as syntaxTree6 } from "@codemirror/language";
4476
4526
  import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
4477
- import { Decoration as Decoration7, EditorView as EditorView18, WidgetType as WidgetType4 } from "@codemirror/view";
4527
+ import { Decoration as Decoration8, EditorView as EditorView19, WidgetType as WidgetType5 } from "@codemirror/view";
4478
4528
  var table = (options = {}) => {
4479
4529
  return StateField8.define({
4480
4530
  create: (state) => update(state, options),
4481
4531
  update: (_, tr) => update(tr.state, options),
4482
- provide: (field) => EditorView18.decorations.from(field)
4532
+ provide: (field) => EditorView19.decorations.from(field)
4483
4533
  });
4484
4534
  };
4485
4535
  var update = (state, _options) => {
@@ -4524,19 +4574,19 @@ var update = (state, _options) => {
4524
4574
  tables.forEach((table2) => {
4525
4575
  const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
4526
4576
  if (replace) {
4527
- builder.add(table2.from, table2.to, Decoration7.replace({
4577
+ builder.add(table2.from, table2.to, Decoration8.replace({
4528
4578
  block: true,
4529
4579
  widget: new TableWidget(table2)
4530
4580
  }));
4531
4581
  } else {
4532
- builder.add(table2.from, table2.to, Decoration7.mark({
4582
+ builder.add(table2.from, table2.to, Decoration8.mark({
4533
4583
  class: "cm-table"
4534
4584
  }));
4535
4585
  }
4536
4586
  });
4537
4587
  return builder.finish();
4538
4588
  };
4539
- var TableWidget = class extends WidgetType4 {
4589
+ var TableWidget = class extends WidgetType5 {
4540
4590
  constructor(_table) {
4541
4591
  super(), this._table = _table;
4542
4592
  }
@@ -4577,14 +4627,14 @@ var Unicode = {
4577
4627
  bulletSmall: "\u2219",
4578
4628
  bulletSquare: "\u2B1D"
4579
4629
  };
4580
- var HorizontalRuleWidget = class extends WidgetType5 {
4630
+ var HorizontalRuleWidget = class extends WidgetType6 {
4581
4631
  toDOM() {
4582
4632
  const el = document.createElement("span");
4583
4633
  el.className = "cm-hr";
4584
4634
  return el;
4585
4635
  }
4586
4636
  };
4587
- var LinkButton = class extends WidgetType5 {
4637
+ var LinkButton = class extends WidgetType6 {
4588
4638
  constructor(url, render) {
4589
4639
  super(), this.url = url, this.render = render;
4590
4640
  }
@@ -4600,7 +4650,7 @@ var LinkButton = class extends WidgetType5 {
4600
4650
  return el;
4601
4651
  }
4602
4652
  };
4603
- var CheckboxWidget = class extends WidgetType5 {
4653
+ var CheckboxWidget = class extends WidgetType6 {
4604
4654
  constructor(_checked) {
4605
4655
  super(), this._checked = _checked;
4606
4656
  }
@@ -4644,7 +4694,7 @@ var CheckboxWidget = class extends WidgetType5 {
4644
4694
  return false;
4645
4695
  }
4646
4696
  };
4647
- var TextWidget = class extends WidgetType5 {
4697
+ var TextWidget = class extends WidgetType6 {
4648
4698
  constructor(text, className) {
4649
4699
  super(), this.text = text, this.className = className;
4650
4700
  }
@@ -4657,29 +4707,29 @@ var TextWidget = class extends WidgetType5 {
4657
4707
  return el;
4658
4708
  }
4659
4709
  };
4660
- var hide = Decoration8.replace({});
4661
- var blockQuote = Decoration8.line({
4710
+ var hide = Decoration9.replace({});
4711
+ var blockQuote = Decoration9.line({
4662
4712
  class: "cm-blockquote"
4663
4713
  });
4664
- var fencedCodeLine = Decoration8.line({
4714
+ var fencedCodeLine = Decoration9.line({
4665
4715
  class: "cm-code cm-codeblock-line"
4666
4716
  });
4667
- var fencedCodeLineFirst = Decoration8.line({
4668
- class: mx2("cm-code cm-codeblock-line", "cm-codeblock-start")
4717
+ var fencedCodeLineFirst = Decoration9.line({
4718
+ class: mx3("cm-code cm-codeblock-line", "cm-codeblock-start")
4669
4719
  });
4670
- var fencedCodeLineLast = Decoration8.line({
4671
- class: mx2("cm-code cm-codeblock-line", "cm-codeblock-end")
4720
+ var fencedCodeLineLast = Decoration9.line({
4721
+ class: mx3("cm-code cm-codeblock-line", "cm-codeblock-end")
4672
4722
  });
4673
4723
  var commentBlockLine = fencedCodeLine;
4674
4724
  var commentBlockLineFirst = fencedCodeLineFirst;
4675
4725
  var commentBlockLineLast = fencedCodeLineLast;
4676
- var horizontalRule = Decoration8.replace({
4726
+ var horizontalRule = Decoration9.replace({
4677
4727
  widget: new HorizontalRuleWidget()
4678
4728
  });
4679
- var checkedTask = Decoration8.replace({
4729
+ var checkedTask = Decoration9.replace({
4680
4730
  widget: new CheckboxWidget(true)
4681
4731
  });
4682
- var uncheckedTask = Decoration8.replace({
4732
+ var uncheckedTask = Decoration9.replace({
4683
4733
  widget: new CheckboxWidget(false)
4684
4734
  });
4685
4735
  var editingRange = (state, range, focus2) => {
@@ -4783,7 +4833,7 @@ var buildDecorations2 = (view, options, focus2) => {
4783
4833
  } else {
4784
4834
  const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
4785
4835
  if (num.length) {
4786
- atomicDeco.add(mark.from, mark.from + len, Decoration8.replace({
4836
+ atomicDeco.add(mark.from, mark.from + len, Decoration9.replace({
4787
4837
  widget: new TextWidget(num, theme.heading(level))
4788
4838
  }));
4789
4839
  }
@@ -4808,7 +4858,7 @@ var buildDecorations2 = (view, options, focus2) => {
4808
4858
  if (node.from === line.to - 1) {
4809
4859
  return false;
4810
4860
  }
4811
- deco.add(line.from, line.from, Decoration8.line({
4861
+ deco.add(line.from, line.from, Decoration9.line({
4812
4862
  class: "cm-list-item",
4813
4863
  attributes: {
4814
4864
  style: `padding-left: ${offset}px; text-indent: -${width}px;`
@@ -4825,7 +4875,7 @@ var buildDecorations2 = (view, options, focus2) => {
4825
4875
  const label = list.type === "OrderedList" ? `${++list.number}.` : Unicode.bulletSmall;
4826
4876
  const line = state.doc.lineAt(node.from);
4827
4877
  const to = state.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
4828
- atomicDeco.add(line.from, to, Decoration8.replace({
4878
+ atomicDeco.add(line.from, to, Decoration9.replace({
4829
4879
  widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
4830
4880
  }));
4831
4881
  break;
@@ -4912,7 +4962,7 @@ var buildDecorations2 = (view, options, focus2) => {
4912
4962
  if (!editing) {
4913
4963
  atomicDeco.add(node.from, marks[0].to, hide);
4914
4964
  }
4915
- deco.add(marks[0].to, marks[1].from, Decoration8.mark({
4965
+ deco.add(marks[0].to, marks[1].from, Decoration9.mark({
4916
4966
  tagName: "a",
4917
4967
  attributes: {
4918
4968
  class: "cm-link",
@@ -4922,7 +4972,7 @@ var buildDecorations2 = (view, options, focus2) => {
4922
4972
  }
4923
4973
  }));
4924
4974
  if (!editing) {
4925
- atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration8.replace({
4975
+ atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration9.replace({
4926
4976
  widget: new LinkButton(url, options.renderLinkButton)
4927
4977
  }) : hide);
4928
4978
  }
@@ -4980,7 +5030,7 @@ var buildDecorations2 = (view, options, focus2) => {
4980
5030
  var forceUpdate = StateEffect5.define();
4981
5031
  var decorateMarkdown = (options = {}) => {
4982
5032
  return [
4983
- ViewPlugin10.fromClass(class {
5033
+ ViewPlugin11.fromClass(class {
4984
5034
  constructor(view) {
4985
5035
  ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
4986
5036
  }
@@ -5012,9 +5062,9 @@ var decorateMarkdown = (options = {}) => {
5012
5062
  }
5013
5063
  }, {
5014
5064
  provide: (plugin) => [
5015
- EditorView19.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
5016
- EditorView19.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
5017
- EditorView19.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration8.none)
5065
+ EditorView20.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration9.none),
5066
+ EditorView20.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration9.none),
5067
+ EditorView20.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration9.none)
5018
5068
  ]
5019
5069
  }),
5020
5070
  image(),
@@ -5723,17 +5773,17 @@ var commands = () => keymap11.of([
5723
5773
 
5724
5774
  // packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
5725
5775
  import { Prec as Prec2 } from "@codemirror/state";
5726
- import { Decoration as Decoration9, EditorView as EditorView20, ViewPlugin as ViewPlugin12 } from "@codemirror/view";
5727
- import { mx as mx3 } from "@dxos/react-ui-theme";
5776
+ import { Decoration as Decoration10, EditorView as EditorView21, ViewPlugin as ViewPlugin13 } from "@codemirror/view";
5777
+ import { mx as mx4 } from "@dxos/react-ui-theme";
5728
5778
 
5729
5779
  // packages/ui/react-ui-editor/src/extensions/outliner/editor.ts
5730
5780
  import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
5731
- import { ViewPlugin as ViewPlugin11 } from "@codemirror/view";
5781
+ import { ViewPlugin as ViewPlugin12 } from "@codemirror/view";
5732
5782
  import { log as log7 } from "@dxos/log";
5733
5783
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/editor.ts";
5734
5784
  var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
5735
5785
  var initialize = () => {
5736
- return ViewPlugin11.fromClass(class {
5786
+ return ViewPlugin12.fromClass(class {
5737
5787
  constructor(view) {
5738
5788
  const first = view.state.doc.lineAt(0);
5739
5789
  const text = view.state.sliceDoc(first.from, first.to);
@@ -5928,20 +5978,20 @@ var outliner = (options = {}) => [
5928
5978
  // Floating menu.
5929
5979
  floatingMenu(),
5930
5980
  // Line decorations.
5931
- decorations(options),
5981
+ decorations(),
5932
5982
  // Default markdown decorations.
5933
5983
  decorateMarkdown({
5934
5984
  listPaddingLeft: 8
5935
5985
  }),
5936
5986
  // Researve space for menu.
5937
- EditorView20.contentAttributes.of({
5987
+ EditorView21.contentAttributes.of({
5938
5988
  class: "is-full !mr-[3rem]"
5939
5989
  })
5940
5990
  ];
5941
- var decorations = (options) => [
5942
- ViewPlugin12.fromClass(class {
5991
+ var decorations = () => [
5992
+ ViewPlugin13.fromClass(class {
5943
5993
  constructor(view) {
5944
- this.decorations = Decoration9.none;
5994
+ this.decorations = Decoration10.none;
5945
5995
  this.updateDecorations(view.state, view);
5946
5996
  }
5947
5997
  update(update2) {
@@ -5963,18 +6013,18 @@ var decorations = (options) => [
5963
6013
  const lineFrom = doc.lineAt(item.contentRange.from);
5964
6014
  const lineTo = doc.lineAt(item.contentRange.to);
5965
6015
  const isSelected = selection.includes(item.index) || item === current;
5966
- decorations2.push(Decoration9.line({
5967
- class: mx3("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
6016
+ decorations2.push(Decoration10.line({
6017
+ class: mx4("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
5968
6018
  }).range(line.from, line.from));
5969
6019
  }
5970
6020
  }
5971
- this.decorations = Decoration9.set(decorations2);
6021
+ this.decorations = Decoration10.set(decorations2);
5972
6022
  }
5973
6023
  }, {
5974
6024
  decorations: (v) => v.decorations
5975
6025
  }),
5976
6026
  // Theme.
5977
- EditorView20.theme(Object.assign({
6027
+ EditorView21.theme(Object.assign({
5978
6028
  ".cm-list-item": {
5979
6029
  borderLeftWidth: "1px",
5980
6030
  borderRightWidth: "1px",
@@ -5998,11 +6048,14 @@ var decorations = (options) => [
5998
6048
  paddingBottom: "4px",
5999
6049
  marginBottom: "2px"
6000
6050
  },
6001
- ".cm-list-item-selected": {
6002
- borderColor: options.showSelected ? "var(--dx-separator)" : void 0
6003
- },
6004
6051
  ".cm-list-item-focused": {
6005
6052
  borderColor: "var(--dx-accentFocusIndicator)"
6053
+ },
6054
+ "[data-has-focus] & .cm-list-item-selected": {
6055
+ borderColor: "var(--dx-separator)"
6056
+ },
6057
+ "[data-is-attention-source] & .cm-list-item-selected": {
6058
+ borderColor: "var(--dx-separator)"
6006
6059
  }
6007
6060
  }))
6008
6061
  ];
@@ -6011,7 +6064,7 @@ var decorations = (options) => [
6011
6064
  import "@dxos/lit-ui/dx-ref-tag.pcss";
6012
6065
  import { syntaxTree as syntaxTree10 } from "@codemirror/language";
6013
6066
  import { RangeSetBuilder as RangeSetBuilder6, StateField as StateField10 } from "@codemirror/state";
6014
- import { Decoration as Decoration10, EditorView as EditorView21, WidgetType as WidgetType6 } from "@codemirror/view";
6067
+ import { Decoration as Decoration11, EditorView as EditorView22, WidgetType as WidgetType7 } from "@codemirror/view";
6015
6068
  var preview = (options = {}) => {
6016
6069
  return [
6017
6070
  // NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
@@ -6020,11 +6073,11 @@ var preview = (options = {}) => {
6020
6073
  create: (state) => buildDecorations3(state, options),
6021
6074
  update: (_, tr) => buildDecorations3(tr.state, options),
6022
6075
  provide: (field) => [
6023
- EditorView21.decorations.from(field),
6024
- EditorView21.atomicRanges.of((view) => view.state.field(field))
6076
+ EditorView22.decorations.from(field),
6077
+ EditorView22.atomicRanges.of((view) => view.state.field(field))
6025
6078
  ]
6026
6079
  }),
6027
- EditorView21.theme({
6080
+ EditorView22.theme({
6028
6081
  ".cm-preview-block": {
6029
6082
  marginLeft: "-1rem",
6030
6083
  marginRight: "-1rem",
@@ -6061,7 +6114,7 @@ var buildDecorations3 = (state, options) => {
6061
6114
  case "Link": {
6062
6115
  const link = getLinkRef(state, node.node);
6063
6116
  if (link) {
6064
- builder.add(node.from, node.to, Decoration10.replace({
6117
+ builder.add(node.from, node.to, Decoration11.replace({
6065
6118
  widget: new PreviewInlineWidget(options, link)
6066
6119
  }));
6067
6120
  }
@@ -6074,7 +6127,7 @@ var buildDecorations3 = (state, options) => {
6074
6127
  case "Image": {
6075
6128
  const link = getLinkRef(state, node.node);
6076
6129
  if (options.renderBlock && link) {
6077
- builder.add(node.from, node.to, Decoration10.replace({
6130
+ builder.add(node.from, node.to, Decoration11.replace({
6078
6131
  block: true,
6079
6132
  // atomic: true,
6080
6133
  widget: new PreviewBlockWidget(options, link)
@@ -6087,7 +6140,7 @@ var buildDecorations3 = (state, options) => {
6087
6140
  });
6088
6141
  return builder.finish();
6089
6142
  };
6090
- var PreviewInlineWidget = class extends WidgetType6 {
6143
+ var PreviewInlineWidget = class extends WidgetType7 {
6091
6144
  constructor(_options, _link) {
6092
6145
  super(), this._options = _options, this._link = _link;
6093
6146
  }
@@ -6104,7 +6157,7 @@ var PreviewInlineWidget = class extends WidgetType6 {
6104
6157
  return root;
6105
6158
  }
6106
6159
  };
6107
- var PreviewBlockWidget = class extends WidgetType6 {
6160
+ var PreviewBlockWidget = class extends WidgetType7 {
6108
6161
  constructor(_options, _link) {
6109
6162
  super(), this._options = _options, this._link = _link;
6110
6163
  }
@@ -6517,8 +6570,8 @@ var createViewMode = (state, onViewModeChange) => {
6517
6570
  };
6518
6571
 
6519
6572
  // packages/ui/react-ui-editor/src/defaults.ts
6520
- import { EditorView as EditorView22 } from "@codemirror/view";
6521
- import { mx as mx4 } from "@dxos/react-ui-theme";
6573
+ import { EditorView as EditorView23 } from "@codemirror/view";
6574
+ import { mx as mx5 } from "@dxos/react-ui-theme";
6522
6575
  var editorWidth = "!mli-auto is-full max-is-[min(50rem,100%-4rem)]";
6523
6576
  var editorSlots = {
6524
6577
  scroll: {
@@ -6528,19 +6581,19 @@ var editorSlots = {
6528
6581
  className: editorWidth
6529
6582
  }
6530
6583
  };
6531
- var editorGutter = EditorView22.theme({
6584
+ var editorGutter = EditorView23.theme({
6532
6585
  ".cm-gutters": {
6533
6586
  paddingRight: "1rem"
6534
6587
  }
6535
6588
  });
6536
- var editorMonospace = EditorView22.theme({
6589
+ var editorMonospace = EditorView23.theme({
6537
6590
  ".cm-content": {
6538
6591
  fontFamily: fontMono
6539
6592
  }
6540
6593
  });
6541
6594
  var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
6542
- var stackItemContentEditorClassNames = (role) => mx4("attention-surface dx-focus-ring-inset data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
6543
- var stackItemContentToolbarClassNames = (role) => mx4("relative z-[1] flex is-full bg-toolbarSurface border-be border-subduedSeparator", role === "section" && "sticky block-start-0 -mbe-px min-is-0");
6595
+ var stackItemContentEditorClassNames = (role) => mx5("attention-surface dx-focus-ring-inset data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
6596
+ var stackItemContentToolbarClassNames = (role) => mx5("relative z-[1] flex is-full bg-toolbarSurface border-be border-subduedSeparator", role === "section" && "sticky block-start-0 -mbe-px min-is-0");
6544
6597
 
6545
6598
  // packages/ui/react-ui-editor/src/components/EditorToolbar/EditorToolbar.tsx
6546
6599
  var createToolbar = ({ getView, state, customActions, ...features }) => {
@@ -6649,7 +6702,7 @@ var EditorToolbar = /* @__PURE__ */ memo(({ classNames, attendableId, role, ...p
6649
6702
  import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
6650
6703
  import { createContext } from "@radix-ui/react-context";
6651
6704
  import React4, { useRef, useState, useEffect as useEffect2, useCallback } from "react";
6652
- import { addEventListener } from "@dxos/async";
6705
+ import { addEventListener as addEventListener2 } from "@dxos/async";
6653
6706
  import { Popover } from "@dxos/react-ui";
6654
6707
  var customEventOptions = {
6655
6708
  capture: true,
@@ -6688,7 +6741,7 @@ var RefPopoverProvider = ({ children, onLookup }) => {
6688
6741
  onLookup
6689
6742
  ]);
6690
6743
  useEffect2(() => {
6691
- return rootRef ? addEventListener(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions) : void 0;
6744
+ return rootRef ? addEventListener2(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions) : void 0;
6692
6745
  }, [
6693
6746
  rootRef
6694
6747
  ]);
@@ -6718,7 +6771,7 @@ var RefPopover = {
6718
6771
  import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
6719
6772
  import { createContext as createContext2 } from "@radix-ui/react-context";
6720
6773
  import React5, { useRef as useRef2, useState as useState2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
6721
- import { addEventListener as addEventListener2 } from "@dxos/async";
6774
+ import { addEventListener as addEventListener3 } from "@dxos/async";
6722
6775
  import { DropdownMenu } from "@dxos/react-ui";
6723
6776
  var customEventOptions2 = {
6724
6777
  capture: true,
@@ -6757,7 +6810,7 @@ var RefDropdownMenuProvider = ({ children, onLookup }) => {
6757
6810
  onLookup
6758
6811
  ]);
6759
6812
  useEffect3(() => {
6760
- return rootRef ? addEventListener2(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions2) : void 0;
6813
+ return rootRef ? addEventListener3(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions2) : void 0;
6761
6814
  }, [
6762
6815
  rootRef
6763
6816
  ]);
@@ -6785,7 +6838,7 @@ var RefDropdownMenu = {
6785
6838
 
6786
6839
  // packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
6787
6840
  import { EditorState as EditorState3 } from "@codemirror/state";
6788
- import { EditorView as EditorView23 } from "@codemirror/view";
6841
+ import { EditorView as EditorView24 } from "@codemirror/view";
6789
6842
  import { useFocusableGroup } from "@fluentui/react-tabster";
6790
6843
  import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef3, useState as useState3 } from "react";
6791
6844
  import { log as log8 } from "@dxos/log";
@@ -6829,7 +6882,7 @@ var useTextEditor = (props = {}, deps = []) => {
6829
6882
  id && documentId.of(id),
6830
6883
  extensions,
6831
6884
  // NOTE: This doesn't catch errors in keymap functions.
6832
- EditorView23.exceptionSink.of((err) => {
6885
+ EditorView24.exceptionSink.of((err) => {
6833
6886
  log8.catch(err, void 0, {
6834
6887
  F: __dxlog_file13,
6835
6888
  L: 98,
@@ -6839,10 +6892,10 @@ var useTextEditor = (props = {}, deps = []) => {
6839
6892
  })
6840
6893
  ].filter(isNotFalsy4)
6841
6894
  });
6842
- view2 = new EditorView23({
6895
+ view2 = new EditorView24({
6843
6896
  parent: parentRef.current,
6844
6897
  state,
6845
- scrollTo: scrollTo ? EditorView23.scrollIntoView(scrollTo, {
6898
+ scrollTo: scrollTo ? EditorView24.scrollIntoView(scrollTo, {
6846
6899
  yMargin: 96
6847
6900
  }) : void 0,
6848
6901
  dispatchTransactions: debug ? debugDispatcher : void 0
@@ -6941,7 +6994,7 @@ export {
6941
6994
  EditorInputModes,
6942
6995
  EditorState4 as EditorState,
6943
6996
  EditorToolbar,
6944
- EditorView24 as EditorView,
6997
+ EditorView25 as EditorView,
6945
6998
  EditorViewMode,
6946
6999
  EditorViewModes,
6947
7000
  Inline,
@@ -7012,6 +7065,7 @@ export {
7012
7065
  getFormatting,
7013
7066
  getListItemContent,
7014
7067
  getRange,
7068
+ hashtag,
7015
7069
  image,
7016
7070
  indentItemLess,
7017
7071
  indentItemMore,